﻿using ITXHWEB.Models;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Web.Mvc;
using WPFExcelReport;
using WPFExcelReport.Helpers;
using ITXHWEB.Infrastructure;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ITXHWEB.Controllers
{
    public partial class ABFOLGEController
    {
        [ChildActionOnly]
        public ActionResult SSTUFF(string returnUrl)
        {
            ModelState.Clear(); 
            ViewBag.ReturnUrl = returnUrl;
            if (!MABF.IsStaffReady)
            {
                INFO = "请扫描有效的员工编号";
            }
            return PartialView(MABF);
        }
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult SSTUFF(ABFOLGEModel model, string returnUrl)
        {
            try
            {
                ModelState.Clear();
                STAFFCHK(model);
            }
            catch (Exception ex)
            {
                INFO = ex.Message;
                Tracer.Error(ex.StackTrace, ex);
            }
            return RedirectToAction(MAPP, MAPP);
        }
        public void STAFFCHK(ABFOLGEModel model)
        {

            MABF.IsStaffReady = false;
            if (model.STAFF == null)
                return;
            var result = HRS.Where(p => p.HRBENID.Trim() == model.STAFF.ToUpper().Trim()).OrderByDescending(p => p.STAFF);
            int remain = result.Count();
            foreach (var m in result)
            {
                MABF.STAFF = m.HRBENID;
                MABF.IsStaffReady = true;
                MABF.IsPDCReady = true;
            }
        } 
    }
}
